package com.markus.code.exam.qushikeji;

import java.util.Scanner;

/**
 * Author:markusZhang
 * Date:Create in 2020/9/12 19:49
 * todo:
 */
public class Main1 {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String str = scanner.nextLine();
        int x = scanner.nextInt();
        Main1 demo = new Main1();
        String ans = demo.dfs(str.length(),str.length()-x,0,str);
        boolean bl = false;
        for (int i=0;i<ans.length();i++){
            if (bl){
                System.out.print(ans.charAt(i));
                continue;
            }
            if (ans.charAt(i) != '0'){
                bl = true;
                System.out.print(ans.charAt(i));
            }
        }
    }
    StringBuilder ans = new StringBuilder();
    private String dfs(int n,int m,int start,String str){
        if (m == 0){
            return ans.toString();
        }
        char c = str.charAt(start);
        int mi = start;
        for (int i=start+1;i<n-(m-1);i++){
            if (c > str.charAt(i)){
               mi = i;
               c = str.charAt(i);
               if (c == '0'){
                   break;
               }
            }
        }
        ans.append(c);
        return dfs(n,m-1,mi+1,str);
    }
}
